package com.vincent.kdp.js;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

import com.google.gson.Gson;
import com.vincent.kdp.Activity.AddConsumeActivity;
import com.vincent.kdp.Activity.QualitypolicyActivity;
import com.vincent.kdp.ui.bean.entity.VipInfo;
import com.vincent.kdp.ui.other.MemberSearchActivity;
import com.vincent.kdp.util.BaseParam;
import com.vincent.kdp.util.GsonUtils;

import org.json.JSONObject;

public class VipInfoOperator {

    private Activity activity;
    private VipInfo vipInfo;

    public VipInfoOperator(Activity activity,VipInfo vipInfo) {
        this.activity = activity;
        this.vipInfo=vipInfo;
    }

    @JavascriptInterface
    public String getDeviceId(){
        return BaseParam.getDeviceId();
    }

    @JavascriptInterface
    public String getVipInfo(){
       return GsonUtils.build().toJson(vipInfo);

    }
    @JavascriptInterface
    public void gotoConsume(){
        Intent intent =new Intent(activity, MemberSearchActivity.class);
        intent.putExtra("phoneOrCard", vipInfo.getPhoneOrCard());
        activity.startActivity(intent);
    }

    @JavascriptInterface
    public void vipInfo(final String barCode, final String goodsName, final String price, final String totalWeight , final String phone , final String deposit){//预定金
        activity.runOnUiThread(new Runnable() {
            public void run() {

                Intent intent =new Intent(activity, AddConsumeActivity.class);
                intent.putExtra("type","vip");
                intent.putExtra("barCode", barCode);
                intent.putExtra("name", goodsName);
                intent.putExtra("price", price);
                intent.putExtra("totalWeight", totalWeight);
                intent.putExtra("phone", phone);
                intent.putExtra("deposit", deposit);

                activity.startActivity(intent);

                }

        });
    }



}  